package com.iot.gateway.aspectj.converter;

import com.iot.gateway.annotation.FieldConverter;

/**
 * 空值转换
 * @param <T>
 */
public class SafeNullConverter<T> implements FieldConverter {

    private final FieldConverter delegate;

    public SafeNullConverter(FieldConverter delegate) {
        this.delegate = delegate;
    }

    @Override
    public Object convert(Object value) {
        try {
            return value == null ? null : delegate.convert(value);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

}
